<%--
 *  @Author: Kevinfan
 *  Date:    4/11/2011
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  //init param
  Category cat = Category.getInstance("jsp.PharmacyPurchaseTypein");
  String strModuleName = "TDR";
  String privilegeCode = "A0403";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc"%>
<html>
<head>
<title>PharmacyPurchaseTypein</title>
<PageFlow:CheckPageFlow pageName="p_datatypein" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/cn/main.css"
	type="text/css">
<link rel="stylesheet" href="<%=contextPath%>/css/autocomplete.css"
	type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/keyFunction.js"></script>
<script type="text/javascript"
	src="<%=contextPath%>/js/spellcode/yahoo-dom-event.js"></script>
<script type="text/javascript"
	src="<%=contextPath%>/js/spellcode/animation-min.js"></script>
<script type="text/javascript"
	src="<%=contextPath%>/js/spellcode/autocomplete.js"></script>
<script type="text/javascript"
	src="<%=contextPath%>/js/spellcode/spellCodeAutoComplete.js"></script>
<script type="text/javascript" src="ZopSaleOrderNew.js"></script>
<%@ include file="/inc/NewCalendar.inc"%>
<script language="JavaScript">
<%
	String year = ((Integer)pageContext.getAttribute("year")).toString();
	String month = ((Integer)pageContext.getAttribute("month")).toString();
	String result = (String)pageContext.getAttribute("result");
	String optionvalue = (String)pageContext.getAttribute("endday1");
	Vector detail = (Vector)pageContext.getAttribute("detail");
	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
	java.util.Calendar cal = java.util.Calendar.getInstance();      
	int day = cal.get(Calendar.DAY_OF_MONTH);
	String periodflag = "false";
	int j = 5;
	if("Y".equals(optionvalue)){
             periodflag = "true";}
	
	if(totalsummary==null)totalsummary = detail;
	if(totalsummary.size()!=0)j=totalsummary.size();
	if(totalsummary.size()==0 && (result.equals("false") || periodflag.equals("false")))j=0;
	if(totalsummary.size()==0 && (month.equals("1") && periodflag.equals("true")))j=5;
%>
function page_save(q){
	var list=document.getElementsByTagName("input");
	window.setTimeout(function(){
	for(var i=0;i<list.length && list[i];i++){
      str = list[i].name;
      if(str.length>11 && str.substr(0,11)=="description"){
      	continue;
      }
      if(list[i].type=="text" && list[i].value==""){
          alert("请填写完整数据！");
          list[i].focus();
          return;
      }
	}
	
	
   var numrows = parseInt(document.getElementById("numrows").value);
	//alert(document.cform.stockqty.value);
	//alert(numrows);
	for(var j=0; j<numrows;j++){
	  stockqty = Number(eval('document.cform.stockqty'+j).value);
	  safestock = Number(eval('document.cform.safestock').value);
	  if(safestock == null){
	    safestock =0;
	  }
	   //alert(stockqty);
	   if(stockqty < 0){
		alert("填报库存不得小于0");
		eval('document.cform.stockqty'+j).value = "";
		eval('document.cform.stockqty'+j).focus();
		return;
	  }
	  if(stockqty < safestock){
		alert("填报库存不得小于该医院安全库存值:" + safestock);
		eval('document.cform.stockqty'+j).value = "";
		eval('document.cform.stockqty'+j).focus();
		return;
	  }
	}
	if(q==1)
		document.cform.strstatus.value = "10";
	else
		document.cform.strstatus.value = "40";
	document.cform.actionname.value = "saves";
    document.cform.target = "_self";
    isRunning = true;
	document.cform.submit();
	},2000);
}

var index;

function page_setHospital(id,name,code,level)
{	
	//document.cform.prodid.value = id;
	eval('document.cform.spellitemcode'+index).value = name;
	document.getElementById("pharmacycode" +index).value = code;
	if(level=="")level = "&nbsp;"
	document.getElementById("tr" +index).cells[5].innerHTML = "&nbsp;"+level;
	eval('document.cform.dealerid'+index).value = id;
	eval('document.cform.dealercode'+index).value = code;
	eval('document.cform.dealername'+index).value = name;
	eval('document.cform.level'+index).value = level;
	hiddenFrm();
	page_getInitialqty(index);
}

function page_setProduct(id,code,name,price,spec)
{	
	eval('document.cform.spellproditemcode'+index).value = name;
	document.getElementById("prodcode" + index).value = code;
	if(spec=="")spec = "&nbsp;"
	document.getElementById("tr" + index).cells[6].innerHTML = spec;
	//if(price=="")price = "&nbsp;"
	//document.getElementById("tr" + index).cells[7].innerHTML = price;
	eval('document.cform.productid'+index).value = id;
	eval('document.cform.productcode'+index).value = code;
	eval('document.cform.productname'+index).value = name;
	if(spec != "&nbsp;")
	eval('document.cform.specifications'+index).value = spec;
	if(price != "&nbsp;")
	eval('document.cform.price'+index).value = price;
	hiddenFrm();
	//page_doSum(eval('document.cform.price'+index),index);
	page_department(index);
	//page_getInitialqty(index);
	setTimeout("page_getInitialqty("+index+");","250");
}

var isHidden;
function frm_select(e,flag,i){
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x -2;
    _obj.style.top = _target.y +  e.clientHeight - 74;
    _obj.style.height="250px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
	index = i;
	var strUrl = "";
	if(flag==1){
		strUrl = "HospitalSelectPop.jsp?maxitem=8&index=" + index + "&<%= OvalTools.randomURL() %>";
	}else if(flag==2){
		strUrl = "OrgSelectPop.jsp?maxitem=8&globalpccode=112&index=" + index + "&<%= OvalTools.randomURL() %>";
	}else if(flag==3){
		_obj.style.height="300px";
		/*alert(i);
		alert(eval('document.cform.productgroupid'+i));
		alert(eval('document.cform.dealerid'+i).value);
		alert(document.cform.dealerid2.value);*/
	   //alert(eval('document.cform.dealerid'+i).value);
	   if(isEmpty(eval('document.cform.dealerid'+i).value)){
	    alert("请先选择医院！");
	    return;
	   }
	   var year = document.cform.year.value;
	   var month = document.cform.month.value;
		strUrl = "ProdSelectPop.jsp?maxitem=10&index=" +index +"&year="+year+"&month="+month+ "&hospitalid="+eval('document.cform.dealerid'+i).value+"&<%= OvalTools.randomURL() %>";
		//alert(strUrl);
	}
    document.summaryfrm.location.href = strUrl;
}
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}
function closeItemSelect(evt)
{
	var _obj = document.getElementById("summaryfrm");
	if(isHidden == "block"){
		isHidden = "none";
	}else{
		_obj.style.display = "none";
	}
	evt = evt || window.event;
        var _target = evt.target || evt.srcElement;
        if (!_target.getAttribute("Author") && _target != inputObj && _target != targetObj) {
            getObjById("Calendar").style.display = "none";
            getObjById("CalendarFrm").style.display = "none";
        }
}

function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

document.onclick=closeItemSelect;   

function page_doSum(obj,idx) 
{
		orgid = eval('document.cform.dealerid'+idx).value;
		productid = eval('document.cform.productid'+idx).value;
		
		if(orgid == "" || orgid==null){
			alert("请先选择医院！");
			eval('document.cform.stockqty'+idx).value = "";
			return;
		}
		if(productid == "" || productid==null){
			alert("请先选择产品！");
			eval('document.cform.stockqty'+idx).value = "";
			return;
		}
		if(obj.value=="" || obj.value=="null")return;
		if (!isNaN(Number(obj.value))){
		var  datahandler = new  DataHandler();
		datahandler.add_params("orgid" , orgid, 'Integer');
		datahandler.add_params("prodid" , productid, 'Integer');
		datahandler.getResult("safestock","document.cform.safestock");
		datahandler.add_job("j_getsafestock");
		datahandler.runDataHandler();
		setTimeout("page_SafeStockError("+idx+");","250");
		}else{
			alert("请输入正确的数值！");
			obj.focus();
		}
}   
function page_SafeStockError(idx){
	if(document.cform.safestock.value=="" || document.cform.safestock.value == null)return;
	stockqty = Number(eval('document.cform.stockqty'+idx).value);
	safestock = Number(document.cform.safestock.value);
	 //alert(stockqty);
	   if(stockqty < 0){
		alert("填报库存不得小于0");
		eval('document.cform.stockqty'+j).value = "";
		eval('document.cform.stockqty'+j).focus();
		return;
	  }
	if(stockqty < safestock){
		alert("填报库存不得小于该医院安全库存值:" + safestock);
		eval('document.cform.stockqty'+idx).value = "";
		eval('document.cform.stockqty'+idx).focus();
	}
} 
function page_checkNum(obj) 
{
		if(obj.value=="")return;
		if (isNaN(Number(obj.value))){
			alert("请输入正确的数值！");
			obj.focus();
		}
}	

function page_delOneDetail(id,flag) {
    var numrows = parseInt(document.getElementById("numrows").value);
    document.getElementById("numrows").value=numrows-1;
    var tableobj = document.getElementById("oTBody");
    var trobj = document.getElementById("tr" + id);
    var onedetailid = "";
	if(flag==1){
		var onedetailid = document.getElementById("tdr_formal_salesdataid" + id).value;
    }
    tableobj.deleteRow(trobj.rowIndex - 1);
    for (var i = 0; i < oTBody.rows.length; i++)
    {
        oTBody.rows[i].cells[0].innerHTML = parseInt(i) + 1;
    }
	if(onedetailid!=""){
		var datahandler = new DataHandler();
		datahandler.add_params("onedetailid", onedetailid, "integer");
		datahandler.add_job("j_delformalsalesdata");
		datahandler.runDataHandler();
	}
	if ( oTBody.rows.length == 0){	 
		addNewRow(1);
	}
}	

function page_getInfoByCode(obj,flag,idx){
	code = obj.value;
	if(code=="")code=-1;
	var  datahandler = new  DataHandler();
	datahandler.add_params("code" , code, 'String');
	if(flag==1){
	datahandler.add_params("querytype" , "hospital", 'String');
	datahandler.getResultFromHashMap("onehash","hospitalid","document.cform.dealerid"+idx);
	datahandler.getResultFromHashMap("onehash","hospitalname","document.cform.dealername"+idx);
	datahandler.getResultFromHashMap("onehash","hospitalcode","document.cform.dealercode"+idx);
	datahandler.getResultFromHashMap("onehash","hospitallevelname","document.cform.level"+idx);
	}else if(flag==2){
	datahandler.add_params("querytype" , "org", 'String');
	datahandler.getResultFromHashMap("onehash","orgid","document.cform.vendorid"+idx);
	datahandler.getResultFromHashMap("onehash","orgcode","document.cform.vendorcode"+idx);
	datahandler.getResultFromHashMap("onehash","orgname","document.cform.vendorname"+idx);
	}else{
	var hospitalid = eval('document.cform.dealerid'+idx).value;
	var year = document.cform.year.value;
	var month = document.cform.month.value;
	 if(isEmpty(eval('document.cform.dealerid'+idx).value)){
	    alert("请先选择医院！");
	    return;
	   }
	datahandler.add_params("hospitalid" ,hospitalid, 'Integer');
	datahandler.add_params("querytype" , "prod", 'String');
	datahandler.add_params("year" ,year, 'Integer');
	datahandler.add_params("month" ,month, 'Integer');
	datahandler.getResultFromHashMap("onehash","prodid","document.cform.productid"+idx);
	datahandler.getResultFromHashMap("onehash","prodcode","document.cform.productcode"+idx);
	datahandler.getResultFromHashMap("onehash","prodname","document.cform.productname"+idx);
	datahandler.getResultFromHashMap("onehash","unitprice","document.cform.price"+idx);
	datahandler.getResultFromHashMap("onehash","spec","document.cform.specifications"+idx);
	}
	datahandler.add_job("j_selectspellcn");
	datahandler.runDataHandler();
	
	setTimeout("page_setValue("+idx+","+flag+");","2000");
 }

function page_setValue(idx,flag){
	dealername = eval('document.cform.dealername'+idx).value;
	level = eval('document.cform.level'+idx).value;
	productname = eval('document.cform.productname'+idx).value;
	specifications = eval('document.cform.specifications'+idx).value;
	price = eval('document.cform.price'+idx).value;
	if(dealername!="null" && dealername!="")
	eval('document.cform.spellitemcode'+idx).value = dealername;
	else
	eval('document.cform.spellitemcode'+idx).value = "";
	if(level!="null" && level!="")
	document.getElementById("tr"+idx).cells[5].innerHTML = level;
	else
	document.getElementById("tr"+idx).cells[5].innerHTML = "&nbsp;";
	if(productname!="null" && productname!="")
	eval('document.cform.spellproditemcode'+idx).value = productname;
	else
	eval('document.cform.spellproditemcode'+idx).value = "";
	if(specifications!="null" && specifications!="")
	document.getElementById("tr"+idx).cells[6].innerHTML = specifications;
	else
	document.getElementById("tr"+idx).cells[6].innerHTML = "&nbsp;";
	//if(price!="null" && price!="")
	//document.getElementById("tr"+idx).cells[7].innerHTML = price;
	//else
	//document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;";
	if(flag==1 && eval('document.cform.dealername'+idx).value == "null"){
		alert("没有符合条件的医院！");
	}else if(flag==2 && eval('document.cform.vendorname'+idx).value == "null"){
		alert("没有符合条件的进货商业！");
	}else if(flag==3 && eval('document.cform.productname'+idx).value == "null"){
		alert("没有符合条件的产品！");
	}
	//page_doSum(eval('document.cform.price'+idx),idx);
	page_getInitialqty(idx);
	if(flag=3) {
	   setTimeout("page_department("+idx+");","500");
	}
}

function clearQik(obj,str){
        if(Trim(obj.value) == '--'+str+'--'){
            obj.value = '';
        }else{
            selectText(obj);
        }
}

function reQik(obj,str){
        if(Trim(obj.value) == ''){
            obj.value = '--'+str+'--';
        }
}
function page_getInitialqty(idx){

	orgid = eval('document.cform.dealerid'+idx).value;
	//alert("page_getInitialqty_orgid:"+orgid);
	productid = eval('document.cform.productid'+idx).value;
	businessdate = eval('document.cform.businessdate'+idx).value;
	var  datahandler = new  DataHandler();
	datahandler.add_params("orgid" , orgid, 'Integer');
	datahandler.add_params("prodid" , productid, 'Integer');
	datahandler.add_params("businessdate" , businessdate, 'Date');
//	datahandler.getResultFromHashMap("onehash","endqty","document.cform.openingnumber"+idx);
	datahandler.getResultFromHashMap("onehash","safeqty","document.cform.pagesafestock");
	datahandler.add_job("j_getendqty");
	
	datahandler.runDataHandler();
	setTimeout("page_setInitialqty("+idx+");","500");
}
 
function page_setInitialqty(idx){
    
	openingnumber = eval('document.cform.openingnumber'+idx).value;
	pagesafestock = cform.pagesafestock.value;
	if(openingnumber!="null" && openingnumber!="")
	document.getElementById("tr"+idx).cells[7].innerHTML = openingnumber;
	else
	document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;";
	if(pagesafestock!="null" && pagesafestock!="")
	document.getElementById("tr"+idx).cells[4].innerHTML = pagesafestock;
	else
	document.getElementById("tr"+idx).cells[4].innerHTML = "&nbsp;";
	
	
}

function page_department(idx){

	orgid = eval('document.cform.dealerid'+idx).value;
	//alert("page_department:orgid ");
	employeeid = eval('document.cform.maker'+idx).value;
	productid = eval('document.cform.productid'+idx).value;
	if(orgid == "" || orgid == "null"){
	
		document.getElementById("tr"+idx).cells[8].innerHTML = "&nbsp;";
		return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("querytype" , 2, 'Integer');
	datahandler.add_params("orgid" , orgid, 'Integer');
	datahandler.add_params("employeeid" , employeeid, 'Integer');
	datahandler.add_params("productid" , productid, 'Integer');
	datahandler.getResultFromHashMap("onehash","productgroupid","document.cform.productgroupid"+idx);
	datahandler.getResultFromHashMap("onehash","productgroupcode","document.cform.productgroupcode"+idx);
	datahandler.getResultFromHashMap("onehash","productgroupname","document.cform.productgroupname"+idx);
	//datahandler.getResultFromHashMap("onehash","orgid","document.cform.dealerid"+idx);
	datahandler.add_job("j_selectgroup");
	datahandler.runDataHandler();
	setTimeout("page_setGroupValue("+idx+");","250");
 }
 
function page_setGroupValue(idx){
    //alert(eval("document.cform.productgroupname"+idx).value);
	if(eval('document.cform.productgroupname'+idx).value!="null" && eval('document.cform.productgroupname'+idx).value!=""){
	  document.getElementById("tr"+idx).cells[8].innerHTML = eval('document.cform.productgroupname'+idx).value;
	}
}

function page_selectbyDate(){
	var year = document.cform.year.value;
	var month = document.cform.month.value;
	self.location="<%=contextPath%>/tdr/datatypein/HospitalSalesTypein.jsp?<%= OvalTools.randomURL() %>&businesstype=150&year="+year+"&month="+month;
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
	scroll="no" class="yui-skin-sam">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher"><input
	type="hidden" name="pagename" value="p_datatypein"> <input
	type="hidden" name="actionname"> <input type="hidden" name="strstatus">
<input type="hidden" name="safestock"> <input type="hidden"
	name="pagesafestock"> <custom:hidden property="businesstype" /> <input
	type="hidden" name="numrows"
	value="<%=totalsummary.size()==0?5:totalsummary.size() %>"> <%
		HashMap employeeinfo = (HashMap)pageContext.getAttribute("employeeinfo");
			String salesmanid = "";
			String salesman = "";                
			String salesmanname = "";            
			String areacode = "";                 
			String areaname = "";               
			String parentemployeeid = "";         
			String parentemployeecode =  "";      
			String parentemployeename = "";         
			String cityname =  "";                
			String citycode = "";
			String parentareacode = "";
			String parentareaname = "";
			String deptid = "";
			String deptcode = "";
			String deptname = "";
		if(employeeinfo.size() !=0){
			salesmanid = ((Integer)employeeinfo.get("userid")).toString();
			salesman = (String)employeeinfo.get("employeecode");                
			salesmanname = (String)employeeinfo.get("employeename");            
			areacode =  "";                
			areaname =  "";              
			parentemployeeid = ((Integer)employeeinfo.get("parentemployeeid")).toString();         
			parentemployeecode =  (String)employeeinfo.get("parentemployeecode");      
			parentemployeename = (String)employeeinfo.get("parentemployeename");         
			cityname =   "";                
			citycode =  "";   
			parentareacode =  ""; 
			parentareaname = ""; 
			deptid =  ""; 
			deptcode =  ""; 
			deptname =  ""; 
		}
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
	style="overflow:scroll">
	<tr>
		<td>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="title-big-b-center">
				<table width="100%" cellspacing="0">
					<tr>
						<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
						<td style="width:50px;" class="td_left"><custom:selectdic
							property="year" dictType="Years" command="notnull"
							value="<%=year %>" label="L_Year1" /></td>
						<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
						<td style="width:50px;" class="td_left"><custom:selectdic
							property="month" dictType="Months" command="notnull"
							value="<%=month %>" label="L_Month" /></td>
						<td style="width:50px;"><a onclick="page_selectbyDate()"><img
							src="<%=contextPath%>/images/cn/ss.png" border="0"></a></td>
						<td><%	
						if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
					%> <script>
							document.getElementById("mydiv").style.height = "360px";
					</script>
						<table width="100%" cellspacing="0">
							<tr>
								<td class="td_right"><custom:button type="1" label="L_Save"
									imgsrc="Modify.gif" border="0" onclick="page_save(1);"
									style="width:55" /></td>
							</tr>
						</table>
						<%}%></td>
					</tr>
					<tr>
						<td class="title-big-b-center" colspan="6">医院库存录入</td>
					</tr>

				</table>
				</td>
			</tr>
			<tr>
				<td class="title-big-b-center">
				<table width="100%" cellspacing="0" border="1"
					bordercolorlight="#999999" bordercolordark="#FFFFFF" align="left"
					style="margin-left:-3;">
					<tr>
						<td class="td-text" width="20%"><%= label.getLabelName("L_YearN") + label.getLabelName("L_Colon")%></td>
						<td width="30%">&nbsp;<%=year%></td>
						<td class="td-text" width="20%"><%= label.getLabelName("L_MonthN") + label.getLabelName("L_Colon")%></td>
						<td width="30%">&nbsp;<%=month%></td>
					</tr>
					<!-- 
					<tr>
						<td class="td-text"><%= label.getLabelName("L_RegionOffice") + label.getLabelName("L_Colon")%></td>
						<td>&nbsp;<%=parentareaname%></td>
						<td class="td-text"><%= label.getLabelName("L_City") + label.getLabelName("L_Colon")%></td>
						<td>&nbsp;<%=cityname%></td>
					</tr>
					 -->
					<tr>
						<td class="td-text"><%= label.getLabelName("L_RegionManager") + label.getLabelName("L_Colon")%></td>
						<td>&nbsp;<%=parentemployeename%></td>
						<td class="td-text"><%= label.getLabelName("L_SalesRep") + label.getLabelName("L_Colon")%></td>
						<td>&nbsp;<%=salesmanname%></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<div id="mydiv" style="width:100%;height=400;overflow=auto;"><iframe
			name="summaryfrm" scrolling="no" frameborder="0"
			style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
		<table id="tab" border="1" cellspacing="0" bordercolorlight="#999999"
			bordercolordark="#FFFFFF" width="100%" cellpadding="1"
			style="position:absolute;overflow:auto;">
			<tr class="deepblue-left">
				<td width="1%"><%= label.getLabelName("L_Nummber") %></td>
				<td class="title_center" width="18%"><%= label.getLabelName("L_Hospital") %></td>
				<td class="title_center" width="18%"><%= label.getLabelName("L_Products") %></td>
				<!--<td class="title_center" width="7%"><%= label.getLabelName("L_SalesQty") %></td>-->
				<td class="title_center" width="8%"><%= label.getLabelName("L_Inventory") %></td>
				<td class="title_center" width="6%"><%= label.getLabelName("L_SafetyStock") %></td>
				<td class="title_center" width="8%"><%= label.getLabelName("L_HospitalGrade") %></td>
				<td class="title_center" width="8%"><%= label.getLabelName("L_Spec") %></td>
				<!--<td class="title_center" width="6%"><%= label.getLabelName("L_UnitPrice") %></td>
    <td class="title_center" width="8%"><%= label.getLabelName("L_SalesAmount") %></td>-->
				<td class="title_center" width="8%"><%= label.getLabelName("L_InitialQty") %></td>
				<td class="title_center" width="8%"><%= label.getLabelName("L_ProductBusiness") %></td>
				<td class="title_center" width="9%"><%= label.getLabelName("L_Comments") %></td>
				<td class="title_center" width="8%"><%= label.getLabelName("L_CreateDate") %></td>
				<!--<td class="title_center" width="7%"><%= label.getLabelName("L_Status") %></td>-->
				<td width="1%">&nbsp;</td>
			</tr>
			<TBODY ID="oTBody">
				<% 
	Integer Status;
	String statusStr = "";
	for(int i=0;i<j;i++){
	if(totalsummary.size()!=0){
		pageContext.setAttribute("onedetail",totalsummary.get(i));
		Status = (Integer)((HashMap)pageContext.getAttribute("onedetail")).get("status");
		statusStr = Status + ""; 
	}
	
	
	
	if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
%>
				<tr id="tr<%=i%>">
					<td><%=i+1%></td>
					<td>
					<div class="spellCode" style="z-index:<%= 4000 - i%>"><input
						type="text" name="spellitemcode<%=i%>" style="width:100px;"
						<%if(totalsummary.size()!=0){%>
						value="<custom:write name="onedetail" property="dealername" nbsp="true"/>"
						<%}else{ %> value="--助记码--" <%} %>
						onfocus="javascript:clearQik(this,'助记码')"
						onchange="javascript:reQik(this,'助记码')">
					<div id="pharmacycodecontainer<%=i%>" class="container"></div>
					</div>
					<label style="width:100px">&nbsp;</label> <input type="text"
						name="pharmacycode<%=i%>" size='10' style=""
						onchange="page_getInfoByCode(this,1,<%=i%>)"
						<%if(totalsummary.size()!=0){%>
						value="<custom:write name="onedetail" property="dealercode"/>"
						<%}else{ %> value="--快速代码--" <%} %>
						onfocus="javascript:clearQik(this,'快速代码')"
						onchange="javascript:reQik(this,'快速代码')"> <script>
            new Oval.SpellCodeAutoComplete({
                inputId: 'spellitemcode<%=i%>',
                containerId: 'pharmacycodecontainer<%=i%>',
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'hospital',
                minQueryStrLength: 2,
                itemPropertyNames: ['hospitalname','hospitalcode','hospitalid','hospitallevelname'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					document.cform.pharmacycode<%=i%>.value = itemProperties[1];					
					if(itemProperties[3]==undefined){itemProperties[3]="&nbsp;";}
					document.getElementById("tr<%=i%>").cells[5].innerHTML = "&nbsp;"+itemProperties[3];
					document.cform.dealerid<%=i%>.value = itemProperties[2];
					document.cform.dealercode<%=i%>.value = itemProperties[1];
					document.cform.dealername<%=i%>.value = itemProperties[0];
					document.cform.level<%=i%>.value = itemProperties[3];
					page_getInitialqty(<%=i%>);
                }

            });
            
            
            
        </script> <a onclick="frm_select(this,1,<%=i%>)"><custom:button
						type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a></td>
					<td>
					<div class="spellCode" style="z-index:<%= 4000 - i%>"><input
						type="text" name="spellproditemcode<%=i%>" style="width:100px;"
						<%if(totalsummary.size()!=0){%>
						value="<custom:write name="onedetail" property="productname" nbsp="true"/>"
						<%}else{ %> value="--助记码--" <%}%>
						onfocus="javascript:clearQik(this,'助记码')"
						onchange="javascript:reQik(this,'助记码')">
					<div id="prodcodecontainer<%=i%>" class="container"></div>
					</div>
					<label style="width:100px">&nbsp;</label> <input type="text"
						name="prodcode<%=i%>" size='10' style=""
						onchange="page_getInfoByCode(this,3,<%=i%>)"
						<%if(totalsummary.size()!=0){%>
						value="<custom:write name="onedetail" property="productcode"/>"
						<%}else{ %> value="--快速代码--" <%} %>
						onfocus="javascript:clearQik(this,'快速代码')"
						onchange="javascript:reQik(this,'快速代码')"> <script>
            new Oval.SpellCodeAutoComplete({
                inputId: 'spellproditemcode<%=i%>',
                containerId: 'prodcodecontainer<%=i%>',
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'prod',
                minQueryStrLength: 2,
                itemPropertyNames: ['prodname','prodcode','prodid','unitprice','spec'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					if(itemProperties[4]==undefined){itemProperties[4]="&nbsp;";}
					document.getElementById("tr<%=i%>").cells[6].innerHTML = "&nbsp;"+itemProperties[4];
					if(itemProperties[3]==undefined){itemProperties[3]="&nbsp;";}
					//document.getElementById("tr<%=i%>").cells[7].innerHTML = "&nbsp;"+itemProperties[3];
					document.cform.productid<%=i%>.value = itemProperties[2];
					document.cform.productcode<%=i%>.value = itemProperties[1];
					document.cform.productname<%=i%>.value = itemProperties[0];
					if(itemProperties[4]!="&nbsp;")
					document.cform.specifications<%=i%>.value = itemProperties[4];
					if(itemProperties[3]!="&nbsp;")
					document.cform.price<%=i%>.value = itemProperties[3];
					document.cform.prodcode<%=i%>.value = itemProperties[1];
					//page_doSum(document.cform.price<%=i%>,<%=i%>);
					page_getInitialqty(<%=i%>);
                }

            });
            
            
        </script> <a onclick="frm_select(this,3,<%=i%>)"><custom:button
						type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a></td>
					<!--<td><input type="text" name="salesqty<%=i%>" size='8' value="<custom:write name="onedetail" property="salesqty"/>" onchange="page_doSum(this,<%=i%>)"/></td>-->
					<td><input type="text" name="stockqty<%=i%>" size='8'
						value="<custom:write name="onedetail" property="stockqty" />"
						onchange="page_doSum(this,<%=i%>)" /></td>
					<td><custom:write name="onedetail" property="safestock" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="level" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="specifications"
						nbsp="true" /></td>
					<!--<td><custom:write name="onedetail" property="price" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="amount" nbsp="true"/></td>-->
					<td><custom:write name="onedetail" property="openingnumber"
						nbsp="true" /></td>
					<td><custom:write name="onedetail" property="productgroupname"
						nbsp="true" /></td>
					<td><custom:text name="onedetail" property="description" size='15'
						colIndex="<%=new Integer(i)%>" /></td>
					<td><custom:write name="onedetail" property="createdate"
						dataType="date" dataFormatName="dateformat" nbsp="true" /></td>
					<!--<td><custom:write dictType="ZylStatus" name="onedetail" property="status" nbsp="true"/></td>-->
					<%}else{%>
				<tr id="tr<%=i%>">
					<td><%=i+1%></td>
					<td><custom:write name="onedetail" property="dealercode"
						nbsp="true" />&nbsp; <custom:write name="onedetail"
						property="dealername" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="productcode"
						nbsp="true" />&nbsp; <custom:write name="onedetail"
						property="productname" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="stockqty" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="safestock" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="level" nbsp="true" /></td>
					<td><custom:write name="onedetail" property="specifications"
						nbsp="true" /></td>
					<td><custom:write name="onedetail" property="openingnumber"
						nbsp="true" /></td>
					<td><custom:write name="onedetail" property="productgroupname"
						nbsp="true" /></td>
					<td><custom:write name="onedetail" property="description"
						nbsp="true" /></td>
					<td><custom:write name="onedetail" property="createdate"
						dataType="date" dataFormatName="dateformat" nbsp="true" /></td>
					<!--<td><custom:write dictType="ZylStatus" name="onedetail" property="status" nbsp="true"/></td>-->


					<%
}
if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
%>
					<td><a onclick="page_delOneDetail('<%=i%>',1)"><img
						src="<%=contextPath%>/images/cn/del1.gif" style="border:none"></a></td>
					<custom:hidden name="onedetail" property="tdr_formal_salesdataid"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="dealerid"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="dealercode"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="dealername"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="level"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="productid"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="productcode"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="productname"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="openingnumber"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="price"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="amount"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="specifications"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="productgroupid"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="productgroupcode"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="productgroupname"
						colIndex="<%= new Integer(i) %>" />
					<custom:hidden name="onedetail" property="status" value="10"
						colIndex="<%=new Integer(i)%>" />

					<custom:hidden name="onedetail" property="year" value="<%=year%>"
						colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="month" value="<%=month%>"
						colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="businesstype" value="150"
						colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="maker"
						value="<%=salesmanid%>"  colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="salesmanid"
						value="<%=salesmanid%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="salesman"
						value="<%=salesman%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="salesmanname"
						value="<%=salesmanname%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="areacode"
						value="<%=areacode%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="areaname"
						value="<%=areaname%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="parentemployeeid"
						value="<%=parentemployeeid%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="parentemployeecode"
						value="<%=parentemployeecode%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="parentemployeename"
						value="<%=parentemployeename%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="cityname"
						value="<%=cityname%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="citycode"
						value="<%=citycode%>" colIndex="<%=new Integer(i)%>" />

					<custom:hidden name="onedetail" property="deptid"
						value="<%=deptid%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="deptcode"
						value="<%=deptcode%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="deptname"
						value="<%=deptname%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="prarentareaname"
						value="<%=parentareaname%>" colIndex="<%=new Integer(i)%>" />
					<custom:hidden name="onedetail" property="prarentareacode"
						value="<%=parentareacode%>" colIndex="<%=new Integer(i)%>" />
					<%String dateStr = year+"-"+month+"-1";%>
					<custom:hidden name="onedetail" property="businessdate"
						value="<%=dateStr%>" colIndex="<%=new Integer(i)%>" />
					<%}else{%>
					<td>&nbsp;</td>
					<%}}%>
				</tr>
			</TBODY>
			<tr>
				<td colspan="24" class="td_left"><%
		if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
	%> <a onclick="addNewRow(5);"> <img
					src="<%=contextPath%>/images/cn/AddRow.gif" border="0"> </a> <%}else{%>
				&nbsp; <%}%></td>
			</tr>
		</table>
		</div>
		</td>
	</tr>
</table>
</form>
<script langauge="javascript">
function addNewRow(num) {
    if (num == 0) return;
    var numrows = parseInt(document.getElementById("numrows").value);
    
    var oRow = oTBody.insertRow();
    for (j = 0; j < 11; j++)
    {
        oCell = oRow.insertCell();
        oCell.innerHTML = "&nbsp;";
    }
    oRow.id = "tr" + numrows;
    oRow.cells[0].innerHTML = oTBody.rows.length;
    var v_str = "<div class=\"spellCode\" style=\"z-index:" + (4000 - numrows) + "\">";
    v_str += "<input type=\"text\" name=\"spellitemcode" + numrows + "\" style=\"width:100px;\" value=\"--助记码--\" onfocus=\"javascript:clearQik(this,'助记码')\" onchange=\"javascript:reQik(this,'助记码')\">";
    v_str += "<div id=\"pharmacycodecontainer" + numrows + "\" class=\"container\"></div>";
    oRow.cells[1].innerHTML = v_str + "</div>";
    oRow.cells[1].innerHTML += "<label style='width:100px'>&nbsp;</label>&nbsp;";
    oRow.cells[1].innerHTML += "<input type=\"text\" name=\"pharmacycode" + numrows + "\"  size='10'  onchange=\"page_getInfoByCode(this,1," + numrows + ")\" value=\"--快速代码--\" style=\"\" onfocus=\"javascript:clearQik(this,'快速代码')\" onchange=\"javascript:reQik(this,'快速代码')\"/>&nbsp;";
    oRow.cells[1].innerHTML += "<a onclick=\"frm_select(this,1," + numrows + ")\"><input type=\"button\" class=\"button3\" imgsrc=\"flash.gif\" border=\"0\" value=\"*\"/></a>";
    
	v_str = "<div class=\"spellCode\" style=\"z-index:" + (4000 - numrows) + "\">";
    v_str += "<input type=\"text\" name=\"spellproditemcode" + numrows + "\" style=\"width:100px;\" value=\"--助记码--\" onfocus=\"javascript:clearQik(this,'助记码')\" onchange=\"javascript:reQik(this,'助记码')\">";
    v_str += "<div id=\"prodcodecontainer" + numrows + "\" class=\"container\"></div>";
    oRow.cells[2].innerHTML = v_str + "</div>";
    oRow.cells[2].innerHTML += "<label style='width:100px'>&nbsp;</label>&nbsp;";
    oRow.cells[2].innerHTML += "<input type=\"text\" name=\"prodcode" + numrows + "\"  size='10'  onchange=\"page_getInfoByCode(this,3," + numrows + ")\" value=\"--快速代码--\" style=\"\" onfocus=\"javascript:clearQik(this,'快速代码')\" onchange=\"javascript:reQik(this,'快速代码')\"/>&nbsp;";
    oRow.cells[2].innerHTML += "<a onclick=\"frm_select(this,3," + numrows + ")\"><input type=\"button\" class=\"button3\" imgsrc=\"flash.gif\" border=\"0\" value=\"*\"/></a>";
	
	//oRow.cells[3].innerHTML = "<input type=\"text\" name=\"salesqty"+numrows+"\" size='8' onchange=\"page_doSum(this,"+numrows+")\"/>";
	oRow.cells[3].innerHTML = "<input type=\"text\" name=\"stockqty"+numrows+"\" size='8' onchange=\"page_doSum(this,"+numrows+")\"/>";
	oRow.cells[9].innerHTML = "<input type=\"text\" name=\"description"+numrows+"\" size='15'/>";
	oRow.cells[10].innerHTML = "<a onclick=\"page_delOneDetail('" + numrows + "');\"><img src='<%=contextPath%>/images/cn/del1.gif' style='border:none'></a>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"dealerid"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"dealername"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"dealercode"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"level"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"productid"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"productcode"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"productname"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"openingnumber"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"price"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"amount"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"productgroupid"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"productgroupcode"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"productgroupname"+numrows+"\"/>";
	
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"specifications"+numrows+"\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"year"+numrows+"\" value=\"<%=year%>\"/> ";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"month"+numrows+"\" value=\"<%=month%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"businesstype"+numrows+"\" value=\"150\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"maker"+numrows+"\" value=\"<%=salesmanid%>\"/>";
	
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"salesmanid"+numrows+"\" value=\"<%=salesmanid%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"salesman"+numrows+"\" value=\"<%=salesman%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"salesmanname"+numrows+"\" value=\"<%=salesmanname%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"areacode"+numrows+"\" value=\"<%=areacode%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"areaname"+numrows+"\" value=\"<%=areaname%>\"/>";
	
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"parentemployeeid"+numrows+"\" value=\"<%=parentemployeeid%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"parentemployeecode"+numrows+"\" value=\"<%=parentemployeecode%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"parentemployeename"+numrows+"\" value=\"<%=parentemployeename%>\"/>";
	
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"deptid"+numrows+"\" value=\"<%=deptid%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"deptcode"+numrows+"\" value=\"<%=deptcode%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"deptname"+numrows+"\" value=\"<%=deptname%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"prarentareaname"+numrows+"\" value=\"<%=parentareaname%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"prarentareacode"+numrows+"\" value=\"<%=parentareacode%>\"/>";
	
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"cityname"+numrows+"\" value=\"<%=cityname%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"citycode"+numrows+"\" value=\"<%=citycode%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"businessdate"+numrows+"\" value=\"<%=year+"-"+month+"-1"%>\"/>";
	oRow.cells[10].innerHTML += "<input type=\"hidden\" name=\"status"+numrows+"\" value=\"10\"/>";
	new Oval.SpellCodeAutoComplete({
                inputId: 'spellitemcode'+ numrows,
                containerId: 'pharmacycodecontainer'+ numrows,
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'hospital',
                minQueryStrLength: 2,
                itemPropertyNames: ['hospitalname','hospitalcode','hospitalid','hospitallevelname'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					eval("document.cform.pharmacycode"+ numrows).value = itemProperties[1];					
					if(itemProperties[3]==undefined){itemProperties[3]="&nbsp;";}
					document.getElementById("tr"+ numrows).cells[5].innerHTML = itemProperties[3];
					eval("document.cform.dealerid"+ numrows).value = itemProperties[2];
					eval("document.cform.dealercode"+ numrows).value = itemProperties[1];
					eval("document.cform.dealername"+ numrows).value = itemProperties[0];
					page_getInitialqty(numrows);
                }

            });
	new Oval.SpellCodeAutoComplete({
                inputId: 'spellproditemcode'+ numrows,
                containerId: 'prodcodecontainer'+ numrows,
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'prod',
                minQueryStrLength: 2,
                itemPropertyNames: ['prodname','prodcode','prodid','unitprice','spec'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					if(itemProperties[4]==undefined){itemProperties[4]="&nbsp;";}
					document.getElementById("tr" + numrows).cells[6].innerHTML = itemProperties[4];
					if(itemProperties[3]==undefined){itemProperties[3]="&nbsp;";}
					//document.getElementById("tr" + numrows).cells[7].innerHTML = itemProperties[3];
					eval("document.cform.productid" + numrows).value = itemProperties[2];
					eval("document.cform.productcode" + numrows).value = itemProperties[1];
					eval("document.cform.productname" + numrows).value = itemProperties[0];
					if(itemProperties[4]!="&nbsp;")
					eval("document.cform.specifications" + numrows).value = itemProperties[4];
					if(itemProperties[3]!="&nbsp;")
					eval("document.cform.price" + numrows).value = itemProperties[3];
					eval("document.cform.prodcode" + numrows).value = itemProperties[1];
					//page_doSum(eval("document.cform.price" + numrows),numrows);
					page_getInitialqty(numrows);
                }

            });
    document.getElementById("numrows").value = numrows + 1;
    addNewRow(num - 1);
 
}
<%	if(detail.size()!=0){%>
//alert("医院库存已成功提交，<%=year%>年<%=month%>月的上报库存不能再次修改！");
<%}%>
</script>
<iframe id="dataLoaderIframe" style="display:none;z-index:5000"></iframe>
</body>
</html>
